package com.tust.app.service.impl;

import com.tust.app.dao.TopicMapper;
import com.tust.app.domain.Topic;
import com.tust.app.service.TopicService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class TopicServiceImpl implements TopicService {

    @Resource
    private TopicMapper TopicMapper;

    @Override
    public List<Topic> selectByUserName(String username){
        if (username != null && username.length() > 0){
            return TopicMapper.selectByUserName(username);
        }else {
            return TopicMapper.selectAllTopics();
        }
    };


    @Override
    public  List<Topic> selectByTitle(String title){
        if (title != null && title.length() > 0){
            return TopicMapper.selectByTitle(title);
        }else {
            return TopicMapper.selectAllTopics();
        }
    };

    @Override
    public List<Topic> topicsList(){
        return TopicMapper.selectAllTopics();
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return TopicMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Topic record) {
        return TopicMapper.insert(record);
    }

    @Override
    public int insertOrUpdate(Topic record) {
        return TopicMapper.insertOrUpdate(record);
    }

    @Override
    public int insertOrUpdateSelective(Topic record) {
        return TopicMapper.insertOrUpdateSelective(record);
    }

    @Override
    public int insertSelective(Topic record) {
        return TopicMapper.insertSelective(record);
    }

    @Override
    public Topic selectByPrimaryKey(Integer id) {
        return TopicMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Topic record) {
        return TopicMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Topic record) {
        return TopicMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateBatch(List<Topic> list) {
        return TopicMapper.updateBatch(list);
    }

    @Override
    public int updateBatchSelective(List<Topic> list) {
        return TopicMapper.updateBatchSelective(list);
    }

    @Override
    public int batchInsert(List<Topic> list) {
        return TopicMapper.batchInsert(list);
    }

}
